<?php 
	include("../../session_ini.php");
	include_once("../../model/ParticipanteService.php");
	
	if(isset($_GET["id_tarea"])){
		include_once("../../model/TareaService.php");
		$service = new TareaService();
		$tarea = $service->getById($_GET["id_tarea"]);
	}
	
	$service2 = new ParticipanteService();
	$usuarios = $service2->getByProyecto($_SESSION["idProyecto"]);
?>
<script type="text/javascript" src="<?php echo URL_BASE(); ?>/view/js/editTarea.js"></script>
<div id="popup">
	<div id="editTarea">
		<h3>
			<?php
			if(isset($_GET["id_tarea"])){
				echo "Tarea";
			}else
			{
				echo "Nueva tarea";
			}
			?>
		</h3>
		<form action="<?php echo URL_BASE(); ?>/controller/editTarea.php" method="POST">
			<label><img alt="" src="<?php echo URL_BASE(); ?>/view/images/bullet-historia.png" class="bullet" />Titulo</label>
			<input type="text" name="titulo" value="<?php echo utf8_encode($tarea->titulo); ?>" id="titulo" class="required" />
			<label><img alt="" src="<?php echo URL_BASE(); ?>/view/images/bullet-historia.png" class="bullet" />Descripci&oacute;n</label>
			<textarea name="descripcion" id="descripcion"><?php echo utf8_encode($tarea->descripcion); ?></textarea>
			<label><img alt="" src="<?php echo URL_BASE(); ?>/view/images/bullet-historia.png" class="bullet" />Deadline</label>
			<input type="text" name="deadline" value="<?php echo $tarea->deadline; ?>" class="datepicker required" id="deadline" />
			<label><img alt="" src="<?php echo URL_BASE(); ?>/view/images/bullet-historia.png" class="bullet" />Asignar</label>
			<select name="id_usuario" id="id_usuario">
				<option value="null">Sin Asignar</option>
				<?php foreach($usuarios as $usuario){ ?>
				<option value="<?php echo $usuario->id; ?>"<?php echo ($usuario->id == $tarea->id_usuario)? " selected='selected'": ""; ?>><?php echo utf8_encode($usuario->nombre); ?></option>
				<?php } ?>
			</select>
			<input type="hidden" name="id_historia" value="<?php echo $_GET["id_historia"]; ?>" id="id_historia" />
			<input type="hidden" name="id" value="<?php echo $_GET["id_tarea"]; ?>" id="id_tarea" />
			<input type="submit" value="Guardar" class="guardar button" />
		</form>
	</div>
</div>